import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

//案例：ArrayList集合存储HashMap元素并遍历
//需求：创建一个ArrayList集合，存储三个元素，每一个元素都是HashMap，每一个HashMap的键和值都是String,并遍历。
public class ArrayListInclHashMap {
    public static void main(String[] args) {
        ArrayList<HashMap<String,String>> alt = new ArrayList<>();
        HashMap<String,String> hm1 = new HashMap<>();
        hm1.put("one","1");
        hm1.put("two","2");
        hm1.put("three","3");
        hm1.put("four","4");

        HashMap<String,String> hm2 = new HashMap<>();
        hm2.put("CCTV1","001");
        hm2.put("CCTV2","002");
        hm2.put("CCTV3","003");
        hm2.put("CCTV4","004");

        HashMap<String,String> hm3 = new HashMap<>();
        hm3.put("1","a");
        hm3.put("2","b");
        hm3.put("3","c");
        hm3.put("4","d");


        alt.add(hm1);
        alt.add(hm2);
        alt.add(hm3);

        for(HashMap<String,String> hm : alt){
            Set<Map.Entry<String, String>> entrySet = hm.entrySet();
            for(Map.Entry<String, String> me : entrySet){
                System.out.println(me.getKey() + " " + me.getValue());
            }
        }


    }
}
